﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using ReportMobile.inc;
using System.Configuration;
using System.Text;

namespace ReportMobile.v2
{
    public partial class Feed_expire_detail : System.Web.UI.Page
    {
        public DataSet dsDetail = new DataSet();
        public DataTable dtDetail;
        public Common comm = new Common();
        public string urlArea, urlName, urlType;
        public StringBuilder sbCompany = new StringBuilder();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["area"] == null) {
                Response.Write("没有需要查看的数据。");
                return;
            }
            urlArea = Request.QueryString["area"];
            urlName = Request.QueryString["name"];
            urlType = Request.QueryString["type"];
            //加工成sql where公司
            string[] authCompany = ConfigurationManager.AppSettings["cyq"].ToString().Split(',');
            for (int i = 0; i < authCompany.Length; i++) {
                sbCompany.Append(",'" + authCompany[i].Trim().Replace(" ", "") + "'");
            }
            sbCompany.Remove(0, 1);
            //结束加工
            if (urlArea == "fcy") {
                if (urlType == "1") {
                    dtDetail = comm.GetExpireDetail(DateTime.Now, urlName);
                }
                else {
                    dtDetail = comm.GetExpireDetail(DateTime.Now.AddDays(-90), urlName);
                }
            }
            else if (urlArea == "cyq") {
                if (urlType == "1") {
                    dtDetail = comm.GetExpireDetail(DateTime.Now, urlName, sbCompany);
                }
                else {
                    dtDetail = comm.GetExpireDetail(DateTime.Now.AddDays(-90), urlName, sbCompany);
                }
            }
            dsDetail.Tables.Add(dtDetail);  //由于这儿始终要报dt已分配给另外的ds了的错误，所以修改了Common类
            rtpExpireDetail.DataSource = dsDetail;
            rtpExpireDetail.DataBind();
            //Response.Write(urlArea + urlName);
            //Response.Write(sbCompany.ToString());
        }
    }
}